package warmachineroster.grapheditor.command;

import org.eclipse.gef.commands.Command;

import warmachineroster.Roster;
import warmachineroster.RosterElement;

public class RosterElementMoveCommand extends Command {

	private Roster roster;
	private RosterElement rosterElement;
	private int oldIndex;
	private int newIndex;

	public void setRoster(Roster roster) {
		this.roster = roster;

	}

	public void setElement(RosterElement childModel) {
		this.rosterElement = childModel;

	}

	public void setOldIndex(int oldIndex) {
		this.oldIndex = oldIndex;

	}

	public void setNewIndex(int newIndex) {
		this.newIndex = newIndex;
	}

	@Override
	public void execute() {
		roster.getRosterUnits().remove(rosterElement);
		roster.getRosterUnits().add(newIndex, rosterElement);
	}

	@Override
	public void undo() {
		roster.getRosterUnits().remove(rosterElement);
		roster.getRosterUnits().add(oldIndex, rosterElement);
	}
	
	

}
